home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
examples
/
chap04
/
LightOnOff.java
< prev
next >
Wrap
Text File
|
1996-09-12
|
649b
|
31 lines
//
// toggle the light state.
//
import vrml.*;
import vrml.node.*;
import vrml.field.*;
public class LightOnOff extends Script{
SFBool turnOnLight;
// light state.
boolean onOff = false;
public void initialize(){
// get the reference of the event out 'turnOnLight'.
turnOnLight = (SFBool)getEventOut("turnOnLight");
}
public void processEvent(Event e){
if(e.getName().equals("touchTime") == true){
// toggle the light state.
onOff = !onOff;
// send the event.
turnOnLight.setValue(onOff);
}
}
}